/* config-overrides.js */
const path = require('path');
const { override, fixBabelImports, addWebpackAlias } = require('customize-cra');

// 仅开发环境，配置代理
const devServer = (configFunction) => (proxy, allowedHost) => {
    const config = configFunction(proxy, allowedHost);
    config.proxy = {
        '/api': {
            target: 'https://www.zjpccb.com',
            // target: 'http://192.168.1.199:12347',// 绍兴
            // target: 'http://192.168.90.102:12347',// 杭州
            changeOrigin: true,
            // pathRewrite: { '^/api': '' },
        },
    };
    return config;
};

module.exports = {
    webpack: override(
        fixBabelImports('import', {
            libraryName: 'antd',
            libraryDirectory: 'es',
            style: 'css',
        }),
        addWebpackAlias({ '@': path.resolve(__dirname, 'src') })
    ),
    devServer,
};